﻿@model IEnumerable<Wicresoft.UnifyShow.Business.BusinessSystemModel>
@{
    Dictionary<decimal, string> idAndSiteNames = (Dictionary<decimal, string>)ViewData["SiteIDAndName"];
    List<decimal> listSiteIDs = Model.Select(o => o.SiteID).Distinct().OrderBy(o => o).ToList();
}
<ul class="treeview" id="bsTree">
    @foreach (var item in listSiteIDs)
    {
        <li><span>@idAndSiteNames[item]</span>
            <ul>
                @foreach (var item1 in Model.Where(o => o.SiteID == item).Select(o => o.Category).Distinct().OrderBy(o => o))
                {
                    <li class="Category"><span>@item1</span>
                        <ul>
                            @foreach (var item2 in Model.Where(o => o.SiteID == item && o.Category == item1).OrderBy(o => o.Name))
                            {
                                <li>
                                    <a href="#@item2.ID" class="node" data-id="@item2.ID">
                                        @if(item2.Name.Length<18){
                                            <span title="@item2.Name">@item2.Name</span>
                                        }
                                        else{
                                            var name1=item2.Name.Substring(0,18).ToString()+"...";
                                            <span title="@item2.Name">@name1</span>
                                        }
                                    </a>
                                </li>
                            }
                        </ul>
                    </li>
                }
            </ul>
        </li>
    }
</ul>
